package com.lagou.homework141;

import java.io.Serializable;

public class Student implements Serializable {

    private String id;
    private String name;
    private int age;

    public Student(String id, String name, int age) throws IdException, AgeException {
        setId(id);
        setName(name);
        setAge(age);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) throws IdException {
        if (id.length() > 1)
            this.id = id;
        else
            throw new IdException("学号不合理！");

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws AgeException {

        if (age > 0 && age < 150)
            this.age = age;
        else
            throw new AgeException("年龄不合理！");
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

